//
//  MailBillViewController.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/6.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class MailBillViewController: BillRootViewController {
    
    fileprivate let cellId = "mailCell"
    fileprivate let dataArray = ["qq_email","email163","email_sina","email126","email139","outlook","email_ali","email_163","email_qita"]
    fileprivate var tableView : UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = mailBill
        createTableView()
    }
    
    //MARK: 创建tableView
    fileprivate func createTableView() {
        
        tableView = UITableView.init(frame: .zero, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.showsVerticalScrollIndicator = false
        tableView.register(MailBillCell.self, forCellReuseIdentifier: cellId)
        self.view.addSubview(tableView)
        
        tableView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.zero)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

        
    }
    

    

}

extension MailBillViewController : UITableViewDelegate,UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return dataArray.count
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        
        return RATIO_H(maxNum: 80)
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as? MailBillCell
        cell?.mailImageView.image = UIImage.imageWithName(dataArray[indexPath.row])
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        let inputMailBillVC = InputMailBillViewController()
        self.navigationController?.pushViewController(inputMailBillVC, animated: true)
    }
    
    
}
